home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / REPLACE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-16  |  5.9 KB  |  191 lines

  1. VERSION 5.00
  2. Begin VB.Form frmReplace 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Global Replace"
  5.    ClientHeight    =   3855
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2070
  8.    ClientWidth     =   5175
  9.    Height          =   4320
  10.    HelpContextID   =   2016091
  11.    Icon            =   "REPLACE.frx":0000
  12.    Left            =   1800
  13.    LinkTopic       =   "Form1"
  14.    LockControls    =   -1  'True
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   3421.786
  18.    ScaleMode       =   0  'User
  19.    ScaleWidth      =   5081.244
  20.    ShowInTaskbar   =   0   'False
  21.    StartUpPosition =   1  'CenterOwner
  22.    Top             =   1665
  23.    Width           =   5295
  24.    Begin VB.ListBox lstTables 
  25.       BackColor       =   &H00FFFFFF&
  26.       Height          =   1650
  27.       Left            =   240
  28.       Sorted          =   -1  'True
  29.       TabIndex        =   1
  30.       Top             =   360
  31.       Width           =   2295
  32.    End
  33.    Begin VB.ListBox lstFields 
  34.       BackColor       =   &H00FFFFFF&
  35.       Height          =   1650
  36.       Left            =   2640
  37.       Sorted          =   -1  'True
  38.       TabIndex        =   3
  39.       Top             =   360
  40.       Width           =   2295
  41.    End
  42.    Begin VB.TextBox txtReplaceWith 
  43.       BackColor       =   &H00FFFFFF&
  44.       Height          =   285
  45.       Left            =   240
  46.       TabIndex        =   5
  47.       Top             =   2280
  48.       Width           =   4695
  49.    End
  50.    Begin VB.TextBox txtCondition 
  51.       BackColor       =   &H00FFFFFF&
  52.       Height          =   285
  53.       Left            =   240
  54.       TabIndex        =   7
  55.       Top             =   2880
  56.       Width           =   4695
  57.    End
  58.    Begin VB.CommandButton cmdOK 
  59.       Caption         =   "&OK"
  60.       Default         =   -1  'True
  61.       Enabled         =   0   'False
  62.       Height          =   375
  63.       Left            =   480
  64.       MaskColor       =   &H00000000&
  65.       TabIndex        =   8
  66.       Top             =   3360
  67.       Width           =   2055
  68.    End
  69.    Begin VB.CommandButton cmdCancel 
  70.       Cancel          =   -1  'True
  71.       Caption         =   "&Cancel"
  72.       Height          =   375
  73.       Left            =   2640
  74.       MaskColor       =   &H00000000&
  75.       TabIndex        =   9
  76.       Top             =   3360
  77.       Width           =   2055
  78.    End
  79.    Begin VB.Label lblLabels 
  80.       AutoSize        =   -1  'True
  81.       Caption         =   "Table:"
  82.       Height          =   195
  83.       Index           =   0
  84.       Left            =   240
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   450
  88.    End
  89.    Begin VB.Label lblLabels 
  90.       AutoSize        =   -1  'True
  91.       Caption         =   "Criteria:"
  92.       Height          =   195
  93.       Index           =   3
  94.       Left            =   240
  95.       TabIndex        =   6
  96.       Top             =   2640
  97.       Width           =   585
  98.    End
  99.    Begin VB.Label lblLabels 
  100.       AutoSize        =   -1  'True
  101.       Caption         =   "Replace With:"
  102.       Height          =   195
  103.       Index           =   2
  104.       Left            =   240
  105.       TabIndex        =   4
  106.       Top             =   2040
  107.       Width           =   1005
  108.    End
  109.    Begin VB.Label lblLabels 
  110.       AutoSize        =   -1  'True
  111.       Caption         =   "Field:"
  112.       Height          =   195
  113.       Index           =   1
  114.       Left            =   2640
  115.       TabIndex        =   2
  116.       Top             =   120
  117.       Width           =   390
  118.    End
  119. Attribute VB_Name = "frmReplace"
  120. Attribute VB_Base = "0{6F48C4DF-C9E4-11CF-9ED2-00AA00574745}"
  121. Attribute VB_GlobalNameSpace = False
  122. Attribute VB_Creatable = False
  123. Attribute VB_TemplateDerived = False
  124. Attribute VB_PredeclaredId = True
  125. Attribute VB_Exposed = False
  126. Attribute VB_Customizable = False
  127. Option Explicit
  128. '>>>>>>>>>>>>>>>>>>>>>>>>
  129. Const FORMCAPTION = "Global Replace"
  130. Const BUTTON1 = "&OK"
  131. Const BUTTON2 = "&Cancel"
  132. Const Label1 = "&Table:"
  133. Const Label2 = "&Field:"
  134. Const LABEL3 = "&Replace With:"
  135. Const LABEL4 = "Cr&iteria:"
  136. Const MSG1 = "Replacing Records"
  137. '>>>>>>>>>>>>>>>>>>>>>>>>
  138. Private Sub cmdCancel_Click()
  139.   Unload Me
  140. End Sub
  141. Private Sub lstFields_Click()
  142.   cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0
  143. End Sub
  144. Private Sub txtReplaceWith_Change()
  145.   cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0
  146. End Sub
  147. Private Sub lstTables_Click()
  148.   Dim i As Integer
  149.   Dim fld As Field
  150.   ListItemNames gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields, lstFields, True
  151. End Sub
  152. Private Sub Form_Load()
  153.   Me.Caption = FORMCAPTION
  154.   cmdOK.Caption = BUTTON1
  155.   cmdCancel.Caption = BUTTON2
  156.   lblLabels(0).Caption = Label1
  157.   lblLabels(1).Caption = Label2
  158.   lblLabels(2).Caption = LABEL3
  159.   lblLabels(3).Caption = LABEL4
  160.   RefreshTables frmReplace.lstTables
  161. End Sub
  162. Private Sub cmdOK_Click()
  163.   Dim sReplaceTxt As String       'replace with string
  164.   Dim sWhereCondition As String   'where condition
  165.   On Error GoTo ReplaceErr
  166.   MsgBar MSG1, True
  167.   If gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields(lstFields).Type = dbText Then
  168.     sReplaceTxt = "'" & txtReplaceWith & "'"
  169.   Else
  170.     sReplaceTxt = txtReplaceWith
  171.   End If
  172.   If Len(txtCondition.Text) = 0 Then
  173.     sWhereCondition = vbNullString
  174.   Else
  175.     sWhereCondition = " where " & txtCondition
  176.   End If
  177.   If gsDataType = gsSQLDB Then
  178.     gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set " & lstFields.Text & "=" & sReplaceTxt & sWhereCondition, dbSQLPassThrough
  179.   Else
  180.     gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set [" & lstFields.Text & "]=" & sReplaceTxt & sWhereCondition
  181.   End If
  182.   If gdbCurrentDB.RecordsAffected > 0 Then
  183.     If gbTransPending Then gbDBChanged = True
  184.   End If
  185.   Unload Me
  186.   MsgBar vbNullString, False
  187.   Exit Sub
  188. ReplaceErr:
  189.   ShowError
  190. End Sub
  191.